﻿using B.S.Data.MES.API.Applications.QualityManagement.ExamineTaskCommand.Commands;
using B.S.Domain.BasicData.QualityManagement;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.QualityManagement.ExamineTaskCommand.CommandHandlers
{
    public class UpdateExamineTaskCommandHandler : IRequestHandler<UpdateExamineTaskCommand, APIRequst<int>>
    {
        private readonly IBaseRepository<ExamineTask> _examintaskRepository;
        public UpdateExamineTaskCommandHandler(IBaseRepository<ExamineTask> examintaskRepository)
        {
            _examintaskRepository = examintaskRepository;
        }
        public Task<APIRequst<int>> Handle(UpdateExamineTaskCommand request, CancellationToken cancellationToken)
        {
            APIRequst<int> result = new APIRequst<int>();
            result.Code = RequstCode.成功;
            result.Msg = RequstCode.成功.ToString();

            ExamineTask task = new ExamineTask();
            task.TaskId = request.TaskId;
            task.TaskNo = request.TaskNo;
            task.QualityType = request.QualityType;
            task.QualityProposal = request.QualityProposal;
            task.TicketCode = request.TicketCode;
            task.PermissionRoleId = request.PermissionRoleId;
            task.CreateName = request.CreateName;
            task.UpdateTime = DateTime.Now;


            _examintaskRepository.Update(task);

            return Task.FromResult(result);
        }
    }
}
